<?php

namespace App\Http\Requests\Backend\Message;

use Illuminate\Foundation\Http\FormRequest;

class HeaderMessageUpdateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title'=>'sometimes|required',
            'desc'=>'sometimes|required',
            'content'=>'sometimes|required',
            'valid_time'=>'sometimes|required',
            'is_h5'=> 'sometimes|required|in:1,2',
            'url'=>'sometimes|required_if:is_h5,1',
        ];
    }

    public function messages()
    {
        return [
            'title.required'=>'公告标题必填',
            'desc.required'=>'说明必填',
            'content.required'=>'消息内容必填',
            'valid_time.required'=>'有效期必填',
            'is_h5.required'=>'是否H5公告必填',
            'is_h5.in'=>'是否H5公告参数错误',
            'url.required_if'=>'H5公告url必填',
        ];
    }
}
